home *** CD-ROM | disk | FTP | other *** search
- ;void crlf(num_lines);
- ; unsigned short num_lines;
-
- EXTRN _memory_model:byte
- EXTRN _error_code:byte
- EXTRN _time_out:byte
-
- _TEXT SEGMENT BYTE PUBLIC 'CODE'
- ASSUME CS:_TEXT
- PUBLIC _crlf
- _crlf proc near
- push bp ;
- mov bp,sp ;set stack frame
- push si ;
- cmp _memory_model,0 ;near or far?
- jle begin ;jump if near
- inc bp ;else add 2 to BP
- inc bp ;
- begin: mov al,_time_out ;get _time_out seconds
- or al,al ;don't allow zero
- jnz L2 ;
- mov al,3 ;default to 3 seconds
- L2: mov cl,18 ;18 ticks per second
- mul cl ;
- mov cx,[bp+4] ;get number lines
- mov [bp+4],ax ;save time out count
- mov ah,1 ;BIOS func to init prtr
- mov _error_code,1 ;1 = printer error
- mov dx,0 ;choose LPT1
- int 17h ;initialize the prtr port
- sub ax,ax ;AX = 0
- mov es,ax ;ES = 0
- mov dx,es:[408H] ;get LPT1 base address
- sub bx,bx ;0 = no error
- jcxz L6 ;quit if zero
- shl cx,1 ;double the number
- mov bh,10 ;LF in BH
- mov ah,13 ;CR in AH
- L3: xchg bh,ah ;xchg the two values
- mov al,bh ;get a value
- out dx,al ;send to output data register
- inc dx ;forward to status register
- push cx ;
- call GetBiosCount ;get timer reading
- mov si,cx ;make copy
- add cx,[bp+4] ;add time out
- cmp si,cx ;if timer doesn't turn over...
- jb L4 ;go ahead
- mov cx,[bp+4] ;time out
- L4: mov [bp+4],cx ;time out
- Wait: in al,dx ;get status value
- test al,8 ;test for printer error
- jz L5 ;
- test al,80h ;test for Printer Ready
- jnz Ready ;jump if ready
- L5: call GetBiosCount ;
- cmp cx,[bp+4] ;compare to time out
- jb Wait ;
- pop cx ;
- jmp short L6 ;go quit routine
- Ready: pop cx ;
- inc dx ;output control register
- mov al,13 ;bits for strobe signal
- out dx,al ;send the signal
- dec al ;change to strobe OFF
- out dx,al ;send the signal
- dec dx ;point back to
- dec dx ; base address
- loop L3 ;go write next char
- dec _error_code ;0 = no error
- L6: pop si ;
- pop bp ;
- cmp _memory_model,0 ;quit
- jle quit ;
- db 0CBh ;RET far
- quit: ret ;RET near
- GetBIOSCount PROC
- push dx ;return value in CX:DX
- push ax ;
- sub ah,ah ;function number
- int 1ah ;get timer count
- mov cx,dx ;low word in CX
- pop ax ;
- pop dx
- ret
- GetBIOSCount endp
- _crlf endp
- _TEXT ENDS
- END